wayland: Don't continue showing if xdg_popup creation failed
authorJonas Ådahl <jadahl@gmail.com>
Sat, 18 Apr 2020 20:51:21 +0000 (22:51 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Sat, 18 Apr 2020 20:57:25 +0000 (22:57 +0200)
We don't create a grabbing popup if it's not the top most one, as that
is a protocol violation, and complain if anything attempts to do it.
What we didn't do is handle this gracefully in the code that tries to
create said popup.

Fix this by dropping the attempt to show the popup on the floor, instead
of setting various state making it look like it succeeded. This won't
actually fix anything, but it'll result in a bit more accurate warnings
logged, as the state more correctly corresponds to the reality.

gdk/wayland/gdksurface-wayland.c

index 5b6c08a5feea42881b6a3ed17c485f2248ec9af4..c644608031ea8fe05ad06d3d3c3a7e2e075aabd8 100644 (file)
@@ -2334,7 +2334,7 @@ can_map_grabbing_popup (GdkSurface *surface,
   return top_most_popup == parent;
 }
 
-static void
+static gboolean
 gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
                                       GdkSurface     *parent,
                                       GdkWaylandSeat *grab_input_seat,
@@ -2348,27 +2348,27 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
   gpointer positioner;
 
   if (!impl->display_server.wl_surface)
-    return;
+    return FALSE;
 
   if (!is_realized_shell_surface (parent))
-    return;
+    return FALSE;
 
   if (is_realized_toplevel (surface))
     {
       g_warning ("Can't map popup, already mapped as toplevel");
-      return;
+      return FALSE;
     }
   if (is_realized_popup (surface))
     {
       g_warning ("Can't map popup, already mapped");
-      return;
+      return FALSE;
     }
 
   if (grab_input_seat &&
       !can_map_grabbing_popup (surface, parent))
     {
       g_warning ("Tried to map a grabbing popup with a non-top most parent");
-      return;
+      return FALSE;
     }
 
   gdk_surface_freeze_updates (surface);
@@ -2453,6 +2453,8 @@ gdk_wayland_surface_create_xdg_popup (GdkSurface     *surface,
       display->current_grabbing_popups =
         g_list_prepend (display->current_grabbing_popups, surface);
     }
+
+  return TRUE;
 }
 
 static GdkWaylandSeat *
@@ -2827,11 +2829,13 @@ gdk_wayland_surface_map_popup (GdkSurface     *surface,
     grab_input_seat = find_grab_input_seat (surface, parent);
   else
     grab_input_seat = NULL;
-  gdk_wayland_surface_create_xdg_popup (surface,
-                                        parent,
-                                        grab_input_seat,
-                                        width, height,
-                                        layout);
+
+  if (!gdk_wayland_surface_create_xdg_popup (surface,
+                                             parent,
+                                             grab_input_seat,
+                                             width, height,
+                                             layout))
+    return;
 
   impl->popup.layout = gdk_popup_layout_copy (layout);
   impl->popup.unconstrained_width = width;